home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume8 / ue310usp < prev    next >
Encoding:
Text File  |  1989-09-23  |  40.8 KB  |  1,433 lines

  1. Newsgroups: comp.sources.misc
  2. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  3. subject: v08i045: Unix support improvements for MicroEMACS 3.10
  4. Reply-To: djm@wam.UMD.EDU (David J. MacKenzie)
  5.  
  6. Posting-number: Volume 8, Issue 45
  7. Submitted-by: djm@wam.UMD.EDU (David J. MacKenzie)
  8. Archive-name: ue310usp
  9.  
  10. [These are, of course, not official patches.  ++bsa]
  11.  
  12. Below I have integrated patches posted by several people to comp.emacs
  13. which fix some bugs and make significant enhancements to MicroEMACS
  14. 3.10 when running under Unix.  Since comp.emacs is not normally
  15. archived (to my knowledge) many people probably missed them, and the
  16. changes made by some of the patches overlap, so I thought it would be a
  17. good idea to merge them all together in one place and post them here.
  18.  
  19. David J. MacKenzie <djm@wam.umd.edu>
  20.  
  21.  
  22. #! /bin/sh
  23. # This is a shell archive.  Remove anything before this line, then unpack
  24. # it by saving it into a file and typing "sh file".  To overwrite existing
  25. # files, type "sh file -c".  You can also feed this as standard input via
  26. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  27. # will see the following message at the end:
  28. #        "End of shell archive."
  29. # Contents:  README patches optional
  30. # Wrapped by dave@zedfdc on Tue Sep 19 12:10:13 1989
  31. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  32. if test -f 'README' -a "${1}" != "-c" ; then 
  33.   echo shar: Will not clobber existing file \"'README'\"
  34. else
  35. echo shar: Extracting \"'README'\" \(1974 characters\)
  36. sed "s/^X//" >'README' <<'END_OF_FILE'
  37. XThe patches in the file `patches' are a merger of the work of the
  38. Xpeople listed below; they are diffs to the virgin MicroEMACS 3.10
  39. Xdistribution that improve its Unix support.  All of the patches except
  40. Xmy Del key fixes were posted to comp.emacs; I have adapted some of them.
  41. X
  42. XThe file `optional' contains some additional patches that change the
  43. Xfunction key support.  I didn't merge it in with the others because
  44. Xit uses a nonportable timing loop and caused unreliable keyboard
  45. Xresponse on my system, and I don't really care about using the function
  46. Xkeys anyway.
  47. X
  48. X  --David MacKenzie
  49. X
  50. X
  51. XMichael Arena <insyte!m2@harvard.harvard.edu>
  52. X    unix.c, input.c: Made filename completion much more efficient.
  53. X
  54. XLinwood Varney <linwood@b11.ingr.com>
  55. X    display.c: If VARARGS is defined, use <varargs.h>, to support systems
  56. X        that pass arguments in registers. 
  57. X    ebind.h, efunc.h: Made job control conditional on JOBCTRL instead
  58. X        of BSD, to support non-BSD systems with job control.
  59. X    unix.c: Made job control conditional on JOBCTRL.
  60. X        Fixed problem with "[End]" message.
  61. X        Fixed filename completion in current directory.
  62. X    input.c: Added ~ (home directory) and environment variable
  63. X        expansion at the beginnings of filenames for ^X^F find-file,
  64. X        et al.
  65. X    edef.h: Changed default value for $ssave to FALSE because it
  66. X        loses Unix files' permissions and ownership.
  67. X    estruct.h: Added JOBCTRL and VARARGS defines.
  68. X
  69. XJohn Rupley <rupley@arizona.edu>
  70. X    unix.c: Fixed bug in USG typeahead code (replaced a k with the
  71. X        high bit set with &k).
  72. X
  73. XHoward Weiss <hsw@tycho.ncsc.mil>
  74. X    tcap.c: Fixed SUN support.
  75. X
  76. XDavid MacKenzie <djm@wam.umd.edu>
  77. X    bind.c: Allow ^? to be used for binding the Del key and in
  78. X        displaying the key bindings.
  79. X    estruct.h: Added DIRENT define.
  80. X    unix.c: Use POSIX <dirent.h> if DIRENT is defined.
  81. X        Fix signal handling for subshell spawning.
  82. X        Implement ^X$ execute-program (run a program without
  83. X        starting up a shell) for real (previously it was the
  84. X        same as ^X! shell-command).
  85. END_OF_FILE
  86. if test 1974 -ne `wc -c <'README'`; then
  87.     echo shar: \"'README'\" unpacked with wrong size!
  88. fi
  89. # end of 'README'
  90. fi
  91. if test -f 'patches' -a "${1}" != "-c" ; then 
  92.   echo shar: Will not clobber existing file \"'patches'\"
  93. else
  94. echo shar: Extracting \"'patches'\" \(25167 characters\)
  95. sed "s/^X//" >'patches' <<'END_OF_FILE'
  96. X*** bind.c.orig    Sat Sep 16 22:32:05 1989
  97. X--- bind.c    Sun Sep 17 01:53:53 1989
  98. X***************
  99. X*** 785,790 ****
  100. X--- 785,795 ----
  101. X          *ptr++ = '^';
  102. X      }
  103. X  
  104. X+     if ((c & 255) == 0x7F) {
  105. X+         *ptr++ = '^';
  106. X+         c = '?';
  107. X+     }
  108. X+ 
  109. X      c = c & 255;    /* strip the prefixes */
  110. X  
  111. X      /* and output the final sequence */
  112. X***************
  113. X*** 910,916 ****
  114. X  
  115. X      Meta and ^X prefix of lower case letters are converted to upper
  116. X      case.  Real control characters are automatically converted to
  117. X!     the ^A form.
  118. X  */
  119. X  
  120. X  unsigned int PASCAL NEAR stock(keyname)
  121. X--- 915,921 ----
  122. X  
  123. X      Meta and ^X prefix of lower case letters are converted to upper
  124. X      case.  Real control characters are automatically converted to
  125. X!     the ^A form.  '^?' is converted to DEL (0x7F).
  126. X  */
  127. X  
  128. X  unsigned int PASCAL NEAR stock(keyname)
  129. X***************
  130. X*** 963,969 ****
  131. X  
  132. X      /* a control char?  (Always upper case) */
  133. X      if (*keyname == '^' && *(keyname+1) != 0) {
  134. X!         c |= CTRL;
  135. X          ++keyname;
  136. X          uppercase(keyname);
  137. X      }
  138. X--- 968,977 ----
  139. X  
  140. X      /* a control char?  (Always upper case) */
  141. X      if (*keyname == '^' && *(keyname+1) != 0) {
  142. X!         if (keyname[1] == '?')
  143. X!             c |= 0x7F;
  144. X!         else
  145. X!             c |= CTRL;
  146. X          ++keyname;
  147. X          uppercase(keyname);
  148. X      }
  149. X***************
  150. X*** 980,986 ****
  151. X          uppercase(keyname);        /* Then make sure it's upper case */
  152. X  
  153. X      /* the final sequence... */
  154. X!     c |= *keyname;
  155. X      return(c);
  156. X  }
  157. X  
  158. X--- 988,995 ----
  159. X          uppercase(keyname);        /* Then make sure it's upper case */
  160. X  
  161. X      /* the final sequence... */
  162. X!     if ((c & 255) != 0x7f)
  163. X!         c |= *keyname;
  164. X      return(c);
  165. X  }
  166. X  
  167. X*** display.c.orig    Sat Sep 16 23:15:39 1989
  168. X--- display.c    Sat Sep 16 23:51:59 1989
  169. X***************
  170. X*** 11,16 ****
  171. X--- 11,19 ----
  172. X  #include    "etype.h"
  173. X  #include    "edef.h"
  174. X  #include    "elang.h"
  175. X+ #if VARARGS
  176. X+ #include    <varargs.h>
  177. X+ #endif
  178. X  
  179. X  typedef struct    VIDEO {
  180. X      int    v_flag;         /* Flags */
  181. X***************
  182. X*** 1091,1096 ****
  183. X--- 1094,1106 ----
  184. X  #define    ADJUST(ptr, dtype)    ptr += sizeof(dtype)
  185. X  #endif
  186. X  
  187. X+ #if VARARGS
  188. X+ CDECL NEAR mlwrite(va_alist)
  189. X+ va_dcl
  190. X+ {
  191. X+     va_list ap;
  192. X+     char *fmt;
  193. X+ #else
  194. X  CDECL NEAR mlwrite(fmt, arg)
  195. X  
  196. X  char *fmt;    /* format string for output */
  197. X***************
  198. X*** 1097,1104 ****
  199. X  char *arg;    /* pointer to first argument to print */
  200. X  
  201. X  {
  202. X-     register int c;     /* current char in format string */
  203. X      register char *ap;    /* ptr to current data field */
  204. X  
  205. X      /* if we are not currently echoing on the command line, abort this */
  206. X      if (discmd == FALSE)
  207. X--- 1107,1115 ----
  208. X  char *arg;    /* pointer to first argument to print */
  209. X  
  210. X  {
  211. X      register char *ap;    /* ptr to current data field */
  212. X+ #endif
  213. X+     register int c;     /* current char in format string */
  214. X  
  215. X      /* if we are not currently echoing on the command line, abort this */
  216. X      if (discmd == FALSE)
  217. X***************
  218. X*** 1116,1124 ****
  219. X--- 1127,1141 ----
  220. X          TTflush();
  221. X      }
  222. X  
  223. X+ #if VARARGS
  224. X+     va_start(ap);
  225. X+     fmt = va_arg(ap, char *);
  226. X+ #endif
  227. X      movecursor(term.t_nrow, 0);
  228. X       lastptr = &lastmesg[0];        /* setup to record message */
  229. X+ #if !VARARGS
  230. X      ap = (char *) &arg;
  231. X+ #endif
  232. X      while ((c = *fmt++) != 0) {
  233. X          if (c != '%') {
  234. X              mlout(c);
  235. X***************
  236. X*** 1127,1159 ****
  237. X--- 1144,1200 ----
  238. X              c = *fmt++;
  239. X              switch (c) {
  240. X                  case 'd':
  241. X+ #if VARARGS
  242. X+                     mlputi(va_arg(ap, int), 10);
  243. X+ #else
  244. X                      mlputi(*(int *)ap, 10);
  245. X                              ADJUST(ap, int);
  246. X+ #endif
  247. X                      break;
  248. X  
  249. X                  case 'o':
  250. X+ #if VARARGS
  251. X+                     mlputi(va_arg(ap, int), 8);
  252. X+ #else
  253. X                      mlputi(*(int *)ap,  8);
  254. X                      ADJUST(ap, int);
  255. X+ #endif
  256. X                      break;
  257. X  
  258. X                  case 'x':
  259. X+ #if VARARGS
  260. X+                     mlputi(va_arg(ap, int), 16);
  261. X+ #else
  262. X                      mlputi(*(int *)ap, 16);
  263. X                      ADJUST(ap, int);
  264. X+ #endif
  265. X                      break;
  266. X  
  267. X                  case 'D':
  268. X+ #if VARARGS
  269. X+                     mlputli(va_arg(ap, long), 10);
  270. X+ #else
  271. X                      mlputli(*(long *)ap, 10);
  272. X                      ADJUST(ap, long);
  273. X+ #endif
  274. X                      break;
  275. X  
  276. X                  case 's':
  277. X+ #if VARARGS
  278. X+                     mlputs(va_arg(ap, char *));
  279. X+ #else
  280. X                      mlputs(*(char **)ap);
  281. X                      ADJUST(ap, char *);
  282. X+ #endif
  283. X                      break;
  284. X  
  285. X                  case 'f':
  286. X+ #if VARARGS
  287. X+                     mlputf(va_arg(ap, int));
  288. X+ #else
  289. X                      mlputf(*(int *)ap);
  290. X                      ADJUST(ap, int);
  291. X+ #endif
  292. X                      break;
  293. X  
  294. X                  default:
  295. X*** ebind.h.orig    Sat Sep 16 23:37:51 1989
  296. X--- ebind.h    Sat Sep 16 23:38:17 1989
  297. X***************
  298. X*** 78,84 ****
  299. X      {CTLX|'A',        BINDFNC,    setvar},
  300. X      {CTLX|'B',        BINDFNC,    usebuffer},
  301. X      {CTLX|'C',        BINDFNC,    spawncli},
  302. X! #if    BSD
  303. X      {CTLX|'D',        BINDFNC,    bktoshell},
  304. X  #endif
  305. X      {CTLX|'E',        BINDFNC,    ctlxe},
  306. X--- 78,84 ----
  307. X      {CTLX|'A',        BINDFNC,    setvar},
  308. X      {CTLX|'B',        BINDFNC,    usebuffer},
  309. X      {CTLX|'C',        BINDFNC,    spawncli},
  310. X! #if    JOBCTRL
  311. X      {CTLX|'D',        BINDFNC,    bktoshell},
  312. X  #endif
  313. X      {CTLX|'E',        BINDFNC,    ctlxe},
  314. X*** edef.h.orig    Thu Jun 15 14:13:52 1989
  315. X--- edef.h    Thu Jun 15 14:10:28 1989
  316. X***************
  317. X*** 41,47 ****
  318. X  NOSHARE int DNEAR sscroll = FALSE;    /* smooth scrolling enabled flag*/
  319. X  NOSHARE int DNEAR hscroll = TRUE;    /* horizontal scrolling flag    */
  320. X  NOSHARE int DNEAR hjump = 1;        /* horizontal jump size     */
  321. X! NOSHARE int DNEAR ssave = TRUE;     /* safe save flag        */
  322. X  NOSHARE struct BUFFER *bstore = NULL;    /* buffer to store macro text to*/
  323. X  NOSHARE int DNEAR vtrow = 0;        /* Row location of SW cursor    */
  324. X  NOSHARE int DNEAR vtcol = 0;        /* Column location of SW cursor */
  325. X--- 41,47 ----
  326. X  NOSHARE int DNEAR sscroll = FALSE;    /* smooth scrolling enabled flag*/
  327. X  NOSHARE int DNEAR hscroll = TRUE;    /* horizontal scrolling flag    */
  328. X  NOSHARE int DNEAR hjump = 1;        /* horizontal jump size     */
  329. X! NOSHARE int DNEAR ssave = FALSE;     /* safe save flag        */
  330. X  NOSHARE struct BUFFER *bstore = NULL;    /* buffer to store macro text to*/
  331. X  NOSHARE int DNEAR vtrow = 0;        /* Row location of SW cursor    */
  332. X  NOSHARE int DNEAR vtcol = 0;        /* Column location of SW cursor */
  333. X*** efunc.h.orig    Sat Sep 16 23:38:37 1989
  334. X--- efunc.h    Sat Sep 16 23:39:07 1989
  335. X***************
  336. X*** 229,235 ****
  337. X  #if    PROC
  338. X      {"store-procedure",        storeproc},
  339. X  #endif
  340. X! #if    BSD
  341. X      {"suspend-emacs",        bktoshell},
  342. X  #endif
  343. X      {"transpose-characters",    twiddle},
  344. X--- 229,235 ----
  345. X  #if    PROC
  346. X      {"store-procedure",        storeproc},
  347. X  #endif
  348. X! #if    JOBCTRL
  349. X      {"suspend-emacs",        bktoshell},
  350. X  #endif
  351. X      {"transpose-characters",    twiddle},
  352. X*** input.c.orig    Thu Jun 15 14:05:11 1989
  353. X--- input.c    Mon Aug 14 13:20:59 1989
  354. X***************
  355. X*** 46,51 ****
  356. X--- 46,59 ----
  357. X  #include    "edef.h"
  358. X  #include    "elang.h"
  359. X  
  360. X+ #if USG | BSD | V7
  361. X+ #include    <pwd.h>
  362. X+ extern    struct passwd *getpwnam();
  363. X+ #if USG
  364. X+ #define    index    strchr
  365. X+ #endif
  366. X+ #endif
  367. X+ 
  368. X  /*
  369. X   * Ask a yes or no question in the message line. Return either TRUE, FALSE, or
  370. X   * ABORT. The ABORT status is returned if the user bumps out of the question
  371. X***************
  372. X*** 209,214 ****
  373. X--- 217,227 ----
  374. X      register int c;        /* current input character */
  375. X      int cpos;        /* current column on screen output */
  376. X      static char buf[NSTRING];/* buffer to hold tentative name */
  377. X+ #if USG | BSD | V7
  378. X+     char *home;
  379. X+     struct passwd *pwd;
  380. X+ #endif
  381. X+ 
  382. X  #if    COMPLET == 0
  383. X      int status;
  384. X  #endif
  385. X***************
  386. X*** 306,313 ****
  387. X              TTflush();
  388. X              if (buf[cpos - 1] == 0)
  389. X                  return(buf);
  390. X          } else {
  391. X!             if (cpos < maxlen && c > ' ') {
  392. X                  buf[cpos++] = c;
  393. X                  mlout(c);
  394. X                  ++ttcol;
  395. X--- 319,394 ----
  396. X              TTflush();
  397. X              if (buf[cpos - 1] == 0)
  398. X                  return(buf);
  399. X+ #if USG | BSD | V7
  400. X+         } else if (c == '/' && type == CMP_FILENAME && buf[0] == '~') {
  401. X+             int i;
  402. X+ 
  403. X+             if (cpos == 1) {
  404. X+                 if (home = (char *)getenv("HOME")) {
  405. X+ 
  406. X+                     mlout('\b');    /* backup over ~ */
  407. X+                     mlout(' ');
  408. X+                     mlout('\b');
  409. X+                     ttcol--;
  410. X+                     TTflush();
  411. X+                     strcpy(buf, home);
  412. X+                     cpos = strlen(buf);
  413. X+                     buf[cpos++] = '/';
  414. X+                     for (i = 0; i < cpos; i++) {
  415. X+                         mlout(buf[i]);
  416. X+                         ttcol++;
  417. X+                     }
  418. X+                     TTflush();
  419. X+                 } else
  420. X+                     goto nextc;
  421. X+             } else {
  422. X+                 buf[cpos] = '\0';
  423. X+                 if (pwd = getpwnam(&buf[1])) {
  424. X+                     while (cpos != 0) {    /* kill    */
  425. X+                         mlout('\b');    /* line    */
  426. X+                         mlout(' ');
  427. X+                         mlout('\b');
  428. X+                         --cpos;
  429. X+                         --ttcol;
  430. X+                     }
  431. X+                     TTflush();
  432. X+                     strcpy(buf, pwd->pw_dir);
  433. X+                     cpos = strlen(buf);
  434. X+                     buf[cpos++] = '/';
  435. X+                     for (i = 0; i < cpos; i++) {
  436. X+                      mlout(buf[i]);
  437. X+                         ttcol++;
  438. X+                     }
  439. X+                     TTflush();
  440. X+                 } else
  441. X+                     goto nextc;
  442. X+             }
  443. X+         } else if (c == '/' && type == CMP_FILENAME && buf[0] == '$') {
  444. X+             int i;
  445. X+ 
  446. X+             buf[cpos] = '\0';
  447. X+             if (home = (char *)getenv(&buf[1])) {
  448. X+                 while (cpos != 0) {    /* kill    */
  449. X+                     mlout('\b');    /* line    */
  450. X+                     mlout(' ');
  451. X+                     mlout('\b');
  452. X+                     --cpos;
  453. X+                     --ttcol;
  454. X+                 }
  455. X+                 TTflush();
  456. X+                 strcpy(buf, home);
  457. X+                 cpos = strlen(buf);
  458. X+                 buf[cpos++] = '/';
  459. X+                 for (i = 0; i < cpos; i++) {
  460. X+                     mlout(buf[i]);
  461. X+                     ttcol++;
  462. X+                 }
  463. X+                 TTflush();
  464. X+             } else
  465. X+                 goto nextc;
  466. X+ #endif
  467. X          } else {
  468. X! nextc:            if (cpos < maxlen && c > ' ') {
  469. X                  buf[cpos++] = c;
  470. X                  mlout(c);
  471. X                  ++ttcol;
  472. X***************
  473. X*** 476,542 ****
  474. X  {
  475. X      register char *fname;    /* trial file to complete */
  476. X      register int index;    /* index into strings to compare */
  477. X!     register char *match;    /* last file that matches string */
  478. X!     register int matchflag;    /* did this file name match? */
  479. X!     register int comflag;    /* was there a completion at all? */
  480. X! 
  481. X!     /* start attempting completions, one character at a time */
  482. X!     comflag = FALSE;
  483. X!     while (*cpos < NBUFN) {
  484. X! 
  485. X!         /* first, we start at the first file and scan the list */
  486. X!         match = NULL;
  487. X!         name[*cpos] = 0;
  488. X!         fname = getffile(name);
  489. X!         while (fname) {
  490. X! 
  491. X!             /* is this a match? */
  492. X!             matchflag = TRUE;
  493. X!             for (index = 0; index < *cpos; index++)
  494. X!                 if (name[index] != fname[index]) {
  495. X!                     matchflag = FALSE;
  496. X!                     break;
  497. X!                 }
  498. X! 
  499. X!             /* if it is a match */
  500. X!             if (matchflag && index) {
  501. X! 
  502. X!                 /* if this is the first match, simply record it */
  503. X!                 if (match == NULL) {
  504. X!                     match = fname;
  505. X!                     name[*cpos] = fname[*cpos];
  506. X!                 } else {
  507. X!                     /* if there's a difference, stop here */
  508. X!                     if (name[*cpos] != fname[*cpos])
  509. X!                         return;
  510. X!                 }
  511. X!             }
  512. X! 
  513. X!             /* on to the next file */
  514. X!             fname = getnfile();
  515. X!         }
  516. X! 
  517. X!         /* with no match, we are done */
  518. X!         if (match == NULL) {
  519. X!             /* beep if we never matched */
  520. X!             if (comflag == FALSE)
  521. X!                 TTbeep();
  522. X!             return;
  523. X!         }
  524. X  
  525. X!         /* if we have completed all the way... go back */
  526. X!         if (name[*cpos] == 0) {
  527. X!             (*cpos)++;
  528. X!             return;
  529. X!         }
  530. X  
  531. X!         /* remember we matched, and complete one character */
  532. X!         comflag = TRUE;
  533. X!         TTputc(name[(*cpos)++]);
  534. X!         TTflush();
  535. X!     }
  536. X  
  537. X-     /* don't allow a completion past the end of the max file name length */
  538. X      return;
  539. X  }
  540. X  #endif
  541. X--- 557,627 ----
  542. X  {
  543. X      register char *fname;    /* trial file to complete */
  544. X      register int index;    /* index into strings to compare */
  545. X!     register int matches;    /* number of matches for name */
  546. X!     char longestmatch[NSTRING]; /* temp buffer for longest match */
  547. X!     int longestlen;        /* length of longest match (always > *cpos) */
  548. X  
  549. X!     /* everything (or nothing) matches an empty string */
  550. X!     if (*cpos == 0)
  551. X!         return;
  552. X! 
  553. X!     /* first, we start at the first file and scan the list */
  554. X!     matches = 0;
  555. X!     name[*cpos] = 0;
  556. X!     fname = getffile(name);
  557. X!     while (fname) {
  558. X! 
  559. X!         /* is this a match? */
  560. X!         if (strncmp(name,fname,*cpos) == 0) {
  561. X! 
  562. X!             /* count the number of matches */
  563. X!             matches++;
  564. X! 
  565. X!             /* if this is the first match, simply record it */
  566. X!             if (matches == 1) {
  567. X!                 strcpy(longestmatch,fname);
  568. X!                 longestlen = strlen(longestmatch);
  569. X!             } else {
  570. X!                 
  571. X!                 /* if there's a difference, stop here */
  572. X!                 if (longestmatch[*cpos] != fname[*cpos])
  573. X!                     return;
  574. X! 
  575. X!                 for (index = (*cpos) + 1; index < longestlen; index++)
  576. X!                     if (longestmatch[index] != fname[index]) {
  577. X!                         longestlen = index;
  578. X!                         longestmatch[longestlen] = 0;
  579. X!                     }
  580. X!             }
  581. X!         }
  582. X! 
  583. X!         /* on to the next file */
  584. X!         fname = getnfile();
  585. X!     }
  586. X! 
  587. X!     /* beep if we never matched */
  588. X!     if (matches == 0) {
  589. X!         TTbeep();
  590. X!         return;
  591. X!     }
  592. X! 
  593. X!     /* the longestmatch array contains the longest match so copy and print it */
  594. X!     for ( ; (*cpos < (NSTRING-1)) && (*cpos < longestlen); (*cpos)++) {
  595. X!         name[*cpos] = longestmatch[*cpos];
  596. X!         TTputc(name[*cpos]);
  597. X!     }
  598. X! 
  599. X!     name[*cpos] = 0;
  600. X! 
  601. X!     /* if only one file matched then increment cpos to signal complete() */
  602. X!     /* that this was a complete match.  If a directory was matched then */
  603. X!     /* last character will be the DIRSEPCHAR.  In this case we do NOT *
  604. X!     /* want to signal a complete match. */
  605. X!     if ((matches == 1) && (name[(*cpos)-1] != DIRSEPCHAR))
  606. X!         (*cpos)++;
  607. X  
  608. X!     TTflush();
  609. X  
  610. X      return;
  611. X  }
  612. X  #endif
  613. X*** tcap.c.orig    Sat Sep 16 22:25:59 1989
  614. X--- tcap.c    Sat Sep 16 22:26:18 1989
  615. X***************
  616. X*** 413,419 ****
  617. X      register int c;
  618. X      register int index;    /* index into termcap binding table */
  619. X      char *sp;
  620. X! #if    BSD | V7 | HPUX
  621. X      int fdset;
  622. X      struct timeval timeout;
  623. X  #endif
  624. X--- 413,419 ----
  625. X      register int c;
  626. X      register int index;    /* index into termcap binding table */
  627. X      char *sp;
  628. X! #if    BSD | V7 | HPUX | SUN
  629. X      int fdset;
  630. X      struct timeval timeout;
  631. X  #endif
  632. X***************
  633. X*** 427,433 ****
  634. X  
  635. X      /* process a possible escape sequence */
  636. X      /* set up to check the keyboard for input */
  637. X! #if    BSD | V7 | HPUX
  638. X      fdset = 1;
  639. X      timeout.tv_sec = 0;
  640. X      timeout.tv_usec = 35000L;
  641. X--- 427,433 ----
  642. X  
  643. X      /* process a possible escape sequence */
  644. X      /* set up to check the keyboard for input */
  645. X! #if    BSD | V7 | HPUX | SUN
  646. X      fdset = 1;
  647. X      timeout.tv_sec = 0;
  648. X      timeout.tv_usec = 35000L;
  649. X***************
  650. X*** 438,444 ****
  651. X          return(CTRL | '[');
  652. X  #endif
  653. X  
  654. X! #if XENIX | SUNOS
  655. X      if ((kbdmode != PLAY) && (rdchk(0) <= 0)) {
  656. X          nap(35000L);
  657. X          if (rdchk(0) <= 0)
  658. X--- 438,444 ----
  659. X          return(CTRL | '[');
  660. X  #endif
  661. X  
  662. X! #if XENIX
  663. X      if ((kbdmode != PLAY) && (rdchk(0) <= 0)) {
  664. X          nap(35000L);
  665. X          if (rdchk(0) <= 0)
  666. X*** unix.c.orig    Thu May 11 13:09:36 1989
  667. X--- unix.c    Sun Sep 17 00:06:10 1989
  668. X***************
  669. X*** 15,21 ****
  670. X--- 15,28 ----
  671. X  #include    <signal.h>
  672. X  #include    <termio.h>
  673. X  #include    <fcntl.h>
  674. X+ #include    <sys/types.h>
  675. X+ #include    <sys/stat.h>
  676. X+ #if    DIRENT
  677. X+ #include    <dirent.h>
  678. X+ #define direct dirent
  679. X+ #else
  680. X  #include    <ndir.h>
  681. X+ #endif
  682. X  int kbdflgs;            /* saved keyboard fd flags    */
  683. X  int kbdpoll;            /* in O_NDELAY mode            */
  684. X  int kbdqp;            /* there is a char in kbdq    */
  685. X***************
  686. X*** 42,55 ****
  687. X  
  688. X  #if BSD
  689. X  #include <sys/ioctl.h>        /* to get at the typeahead */
  690. X- extern    int rtfrmshell();    /* return from suspended shell */
  691. X  #define    TBUFSIZ    128
  692. X  char tobuf[TBUFSIZ];        /* terminal output buffer */
  693. X  #endif
  694. X  #endif
  695. X  
  696. X  #if     V7 | USG | HPUX | SUN | XENIX | BSD
  697. X- #include        <signal.h>
  698. X  extern int vttidy();
  699. X  #endif
  700. X  
  701. X--- 49,64 ----
  702. X  
  703. X  #if BSD
  704. X  #include <sys/ioctl.h>        /* to get at the typeahead */
  705. X  #define    TBUFSIZ    128
  706. X  char tobuf[TBUFSIZ];        /* terminal output buffer */
  707. X  #endif
  708. X  #endif
  709. X  
  710. X+ #if JOBCTRL
  711. X+ extern    int rtfrmshell();    /* return from suspended shell */
  712. X+ #endif
  713. X+ 
  714. X  #if     V7 | USG | HPUX | SUN | XENIX | BSD
  715. X  extern int vttidy();
  716. X  #endif
  717. X  
  718. X***************
  719. X*** 75,80 ****
  720. X--- 84,94 ----
  721. X      kbdpoll = FALSE;
  722. X  #endif
  723. X  
  724. X+ #if    JOBCTRL
  725. X+     signal(SIGTSTP,SIG_DFL);    /* set signals so that we can */
  726. X+     signal(SIGCONT,rtfrmshell);    /* suspend & restart emacs */
  727. X+ #endif
  728. X+ 
  729. X  #if     V7 | BSD
  730. X          gtty(0, &ostate);                       /* save old state */
  731. X          gtty(0, &nstate);                       /* get base of new state */
  732. X***************
  733. X*** 87,96 ****
  734. X      /* provide a smaller terminal output buffer so that
  735. X         the type ahead detection works better (more often) */
  736. X      setbuffer(stdout, &tobuf[0], TBUFSIZ);
  737. X-     signal(SIGTSTP,SIG_DFL);    /* set signals so that we can */
  738. X-     signal(SIGCONT,rtfrmshell);    /* suspend & restart emacs */
  739. X  #endif
  740. X  #endif
  741. X      /* on all screens we are not sure of the initial position
  742. X         of the cursor                    */
  743. X      ttrow = 999;
  744. X--- 101,112 ----
  745. X      /* provide a smaller terminal output buffer so that
  746. X         the type ahead detection works better (more often) */
  747. X      setbuffer(stdout, &tobuf[0], TBUFSIZ);
  748. X  #endif
  749. X  #endif
  750. X+     /* if we spawn a subshell we don't want to die if the user hits
  751. X+        the interrupt or quit keys */
  752. X+     signal(SIGINT, SIG_IGN);
  753. X+     signal(SIGQUIT, SIG_IGN);
  754. X      /* on all screens we are not sure of the initial position
  755. X         of the cursor                    */
  756. X      ttrow = 999;
  757. X***************
  758. X*** 217,223 ****
  759. X          if (fcntl(0, F_SETFL, kbdflgs | O_NDELAY) < 0 && kbdpoll)
  760. X              return(FALSE);
  761. X          kbdpoll = TRUE;
  762. X!         kbdqp = (1 == read(0, kbdq, 1));
  763. X      }
  764. X      return(kbdqp);
  765. X  #endif
  766. X--- 233,239 ----
  767. X          if (fcntl(0, F_SETFL, kbdflgs | O_NDELAY) < 0 && kbdpoll)
  768. X              return(FALSE);
  769. X          kbdpoll = TRUE;
  770. X!         kbdqp = (1 == read(0, &kbdq, 1));
  771. X      }
  772. X      return(kbdqp);
  773. X  #endif
  774. X***************
  775. X*** 259,265 ****
  776. X          return(TRUE);
  777. X  }
  778. X  
  779. X! #if    BSD
  780. X  
  781. X  bktoshell()        /* suspend MicroEMACS and wait to wake up */
  782. X  {
  783. X--- 275,281 ----
  784. X          return(TRUE);
  785. X  }
  786. X  
  787. X! #if    JOBCTRL
  788. X  
  789. X  bktoshell()        /* suspend MicroEMACS and wait to wake up */
  790. X  {
  791. X***************
  792. X*** 299,311 ****
  793. X          TTclose();                              /* stty to old modes    */
  794. X          system(line);
  795. X          TTopen();
  796. X!         TTflush();
  797. X      /* if we are interactive, pause here */
  798. X      if (clexec == FALSE) {
  799. X              mlputs(TEXT6);
  800. X  /*                     "\r\n\n[End]" */
  801. X              tgetc();
  802. X          }
  803. X          sgarbf = TRUE;
  804. X          return(TRUE);
  805. X  }
  806. X--- 315,329 ----
  807. X          TTclose();                              /* stty to old modes    */
  808. X          system(line);
  809. X          TTopen();
  810. X!         movecursor(term.t_nrow, 0);             /* Seek to last line.   */
  811. X      /* if we are interactive, pause here */
  812. X      if (clexec == FALSE) {
  813. X              mlputs(TEXT6);
  814. X  /*                     "\r\n\n[End]" */
  815. X+             TTflush();
  816. X              tgetc();
  817. X          }
  818. X+     TTflush();
  819. X          sgarbf = TRUE;
  820. X          return(TRUE);
  821. X  }
  822. X***************
  823. X*** 317,323 ****
  824. X   */
  825. X  
  826. X  execprg(f, n)
  827. X- 
  828. X  {
  829. X          register int    s;
  830. X          char            line[NLINE];
  831. X--- 335,340 ----
  832. X***************
  833. X*** 326,348 ****
  834. X      if (restflag)
  835. X          return(resterr());
  836. X  
  837. X!         if ((s=mlreply("!", line, NLINE)) != TRUE)
  838. X                  return(s);
  839. X          TTputc('\n');                /* Already have '\r'    */
  840. X          TTflush();
  841. X          TTclose();                              /* stty to old modes    */
  842. X!         system(line);
  843. X          TTopen();
  844. X!         mlputs(TEXT188);                        /* Pause.               */
  845. X! /*             "[End]" */
  846. X!         TTflush();
  847. X!         while ((s = tgetc()) != '\r' && s != ' ')
  848. X!                 ;
  849. X          sgarbf = TRUE;
  850. X          return(TRUE);
  851. X  }
  852. X  
  853. X  /*
  854. X   * Pipe a one line command into a window
  855. X   * Bound to ^X @
  856. X   */
  857. X--- 343,502 ----
  858. X      if (restflag)
  859. X          return(resterr());
  860. X  
  861. X!         if ((s=mlreply("$", line, NLINE)) != TRUE)
  862. X                  return(s);
  863. X          TTputc('\n');                /* Already have '\r'    */
  864. X          TTflush();
  865. X          TTclose();                              /* stty to old modes    */
  866. X!         execpr(line);
  867. X          TTopen();
  868. X!         movecursor(term.t_nrow, 0);             /* Seek to last line.   */
  869. X!     /* if we are interactive, pause here */
  870. X!     if (clexec == FALSE) {
  871. X!             mlputs(TEXT188);
  872. X! /*                     "[End]" */
  873. X!             TTflush();
  874. X!             tgetc();
  875. X!         }
  876. X!     TTflush();
  877. X          sgarbf = TRUE;
  878. X          return(TRUE);
  879. X  }
  880. X  
  881. X  /*
  882. X+  * Run a program with arguments without using a shell.
  883. X+  * Line is a string containing a program name and arguments, separated
  884. X+  * by whitespace.  Shell metacharacters have no special meaning.
  885. X+  */
  886. X+ 
  887. X+ execpr(line)
  888. X+     char           *line;
  889. X+ {
  890. X+     char          **stov();
  891. X+     char          **argv;
  892. X+     char           *cp;    /* A copy of the line in case it's $SHELL. */
  893. X+     int             pid;
  894. X+ 
  895. X+     if (line == 0 || *line == 0)
  896. X+         return;
  897. X+ 
  898. X+     cp = malloc(strlen(line) + 1);
  899. X+     strcpy(cp, line);
  900. X+     argv = stov(cp);
  901. X+ 
  902. X+     pid = fork();
  903. X+     switch (pid) {
  904. X+     case -1:
  905. X+         break;
  906. X+     case 0:        /* Child. */
  907. X+         signal(SIGINT, SIG_DFL);
  908. X+         signal(SIGQUIT, SIG_DFL);
  909. X+         execvp(argv[0], argv);
  910. X+         /* Might want to print "argv[0]: Command not found.\n". */
  911. X+         exit(0);
  912. X+     default:        /* Parent. */
  913. X+         while (wait((int *) 0) != pid)
  914. X+              /* Do nothing. */ ;
  915. X+         break;
  916. X+     }
  917. X+     free(argv);
  918. X+     free(cp);
  919. X+ }
  920. X+ 
  921. X+ /* Number of arguments between realloc's. */
  922. X+ #define ALLOC_BLOCK 10
  923. X+ 
  924. X+ /*
  925. X+  * Make an argv-like vector (string array) from a string (such as an
  926. X+  * environment variable).  The last element of the vector is null.
  927. X+  * Scatters nulls throughout s.
  928. X+  */
  929. X+ 
  930. X+ char **
  931. X+ stov(s)
  932. X+     char           *s;    /* The string to vectorize. */
  933. X+ {
  934. X+     char           *malloc(), *realloc(), *strtok();
  935. X+     int             argc;
  936. X+     char          **argv;
  937. X+ 
  938. X+     argc = 0;
  939. X+     argv = (char **) malloc((unsigned) (sizeof(char *) * ALLOC_BLOCK));
  940. X+ 
  941. X+     for (s = strtok(s, " \t\n\r"); s;
  942. X+         s = strtok((char *) NULL, " \t\n\r")) {
  943. X+         if (argc > 0 && argc % ALLOC_BLOCK == 0)
  944. X+             argv = (char **) realloc((char *) argv, (unsigned)
  945. X+                 (sizeof(char *) * (argc + ALLOC_BLOCK)));
  946. X+         argv[argc++] = s;
  947. X+     }
  948. X+     argv = (char **) realloc((char *) argv,
  949. X+         (unsigned) (sizeof(char *) * (argc + 1)));
  950. X+     argv[argc] = NULL;
  951. X+     return argv;
  952. X+ }
  953. X+ 
  954. X+ #if V7 | BSD
  955. X+ /* Return the next token in string, delimited by one or more members of
  956. X+    the set separators.  If string is NULL, use the same string as in the
  957. X+    last call.  */
  958. X+ 
  959. X+ char *
  960. X+ strtok(string, separators)
  961. X+     char           *string;
  962. X+     char           *separators;
  963. X+ {
  964. X+     static char    *pos = NULL;    /* Current location in the string. */
  965. X+     register int    token_length;
  966. X+ 
  967. X+     if (string)
  968. X+         pos = string;
  969. X+     pos += strspn(pos, separators);    /* Skip initial separators. */
  970. X+     token_length = strcspn(pos, separators);    /* Find token length. */
  971. X+     if (token_length == 0)
  972. X+         return NULL;    /* No more tokens; pos is on a 0. */
  973. X+     separators = pos;    /* Re-use separators to save start of token. */
  974. X+     pos += token_length;    /* Move onto the 0. */
  975. X+     if (*pos)        /* If not the last token, */
  976. X+         *pos++ = 0;    /* null terminate the token. */
  977. X+     return separators;
  978. X+ }
  979. X+ 
  980. X+ /* Return the length of the span of characters at the start of string
  981. X+    that are members of class.  */
  982. X+ 
  983. X+ strspn(string, class)
  984. X+     char           *string;
  985. X+     char           *class;
  986. X+ {
  987. X+     char           *index();
  988. X+     register int    count;
  989. X+ 
  990. X+     for (count = 0; string[count]; ++count)
  991. X+         if (!index(class, string[count]))
  992. X+             break;
  993. X+     return count;
  994. X+ }
  995. X+ 
  996. X+ /* Return the length of the span of characters at the start of string
  997. X+    that are non-members of class.  */
  998. X+ 
  999. X+ strcspn(string, class)
  1000. X+     char           *string;
  1001. X+     char           *class;
  1002. X+ {
  1003. X+     char           *index();
  1004. X+     register int    count;
  1005. X+ 
  1006. X+     for (count = 0; string[count]; ++count)
  1007. X+         if (index(class, string[count]))
  1008. X+             break;
  1009. X+     return count;
  1010. X+ }
  1011. X+ 
  1012. X+ #endif
  1013. X+ 
  1014. X+ /*
  1015. X   * Pipe a one line command into a window
  1016. X   * Bound to ^X @
  1017. X   */
  1018. X***************
  1019. X*** 529,534 ****
  1020. X--- 683,689 ----
  1021. X      register int index;        /* index into various strings */
  1022. X      register int point;        /* index into other strings */
  1023. X      register int extflag;        /* does the file have an extention? */
  1024. X+     int currentdir = FALSE;
  1025. X  
  1026. X      /* first parse the file path off the file spec */
  1027. X      strcpy(path, fspec);
  1028. X***************
  1029. X*** 537,542 ****
  1030. X--- 692,704 ----
  1031. X                  path[index] != '\\' && path[index] != ':'))
  1032. X          --index;
  1033. X      path[index+1] = 0;
  1034. X+ #if HPUX
  1035. X+     if (index < 0) {
  1036. X+         strcpy(path,"./");
  1037. X+         index = 1;
  1038. X+         currentdir = TRUE;
  1039. X+     }
  1040. X+ #endif
  1041. X  
  1042. X      /* check for an extension */
  1043. X      point = strlen(fspec) - 1;
  1044. X***************
  1045. X*** 554,563 ****
  1046. X          closedir(dirptr);
  1047. X          dirptr = NULL;
  1048. X      }
  1049. X!     dirptr = opendir(path);
  1050. X      if (dirptr == NULL)
  1051. X          return(NULL);
  1052. X  
  1053. X      strcpy(rbuf, path);
  1054. X      nameptr = &rbuf[strlen(rbuf)];
  1055. X  
  1056. X--- 716,733 ----
  1057. X          closedir(dirptr);
  1058. X          dirptr = NULL;
  1059. X      }
  1060. X!     if (path[0])
  1061. X!         dirptr = opendir(path);
  1062. X!     else
  1063. X!         dirptr = opendir(".");
  1064. X      if (dirptr == NULL)
  1065. X          return(NULL);
  1066. X  
  1067. X+ #if HPUX
  1068. X+     if (currentdir == TRUE)
  1069. X+         path[0] = '\0';
  1070. X+ #endif
  1071. X+ 
  1072. X      strcpy(rbuf, path);
  1073. X      nameptr = &rbuf[strlen(rbuf)];
  1074. X  
  1075. X***************
  1076. X*** 580,591 ****
  1077. X      /* check to make sure we skip directory entries */
  1078. X      strcpy(nameptr, dp->d_name);
  1079. X      stat(rbuf, &fstat);
  1080. X!     if ((fstat.st_mode & S_IFMT) != S_IFREG)
  1081. X          goto nxtdir;
  1082. X  
  1083. X      /* return the next file name! */
  1084. X      return(rbuf);
  1085. X  }
  1086. X  #else
  1087. X  char *PASCAL NEAR getffile(fspec)
  1088. X  
  1089. X--- 750,766 ----
  1090. X      /* check to make sure we skip directory entries */
  1091. X      strcpy(nameptr, dp->d_name);
  1092. X      stat(rbuf, &fstat);
  1093. X!     if (((fstat.st_mode & S_IFMT) != S_IFREG) &&
  1094. X!         ((fstat.st_mode & S_IFMT) != S_IFDIR))
  1095. X          goto nxtdir;
  1096. X  
  1097. X+     if ((fstat.st_mode & S_IFMT) == S_IFDIR)
  1098. X+         strcat(rbuf,"/");
  1099. X+ 
  1100. X      /* return the next file name! */
  1101. X      return(rbuf);
  1102. X  }
  1103. X+ 
  1104. X  #else
  1105. X  char *PASCAL NEAR getffile(fspec)
  1106. X  
  1107. X*** estruct.h.orig    Tue Sep 19 11:44:15 1989
  1108. X--- estruct.h    Tue Sep 19 11:45:37 1989
  1109. X***************
  1110. X*** 52,57 ****
  1111. X--- 52,62 ----
  1112. X  #define WMCS    0            /* Wicat's MCS            */
  1113. X  #define    AOSVS    0            /* Data General AOS/VS        */
  1114. X  
  1115. X+ /* Additional settings for Unix systems        */
  1116. X+ #define DIRENT  1            /* has POSIX <dirent.h> library    */
  1117. X+ #define JOBCTRL    0            /* has BSD job control        */
  1118. X+ #define VARARGS    1            /* has Unix <varargs.h>        */
  1119. X+ 
  1120. X  /*    Compiler definitions            */
  1121. X  /*    [Set one of these!!]            */
  1122. X  #define UNIX    0    /* a random UNIX compiler */
  1123. END_OF_FILE
  1124. echo shar: 1 control character may be missing from \"'patches'\"
  1125. if test 25167 -ne `wc -c <'patches'`; then
  1126.     echo shar: \"'patches'\" unpacked with wrong size!
  1127. fi
  1128. # end of 'patches'
  1129. fi
  1130. if test -f 'optional' -a "${1}" != "-c" ; then 
  1131.   echo shar: Will not clobber existing file \"'optional'\"
  1132. else
  1133. echo shar: Extracting \"'optional'\" \(10811 characters\)
  1134. sed "s/^X//" >'optional' <<'END_OF_FILE'
  1135. XArticle 5159 of comp.emacs:
  1136. XPath: rocky8!cmcl2!rutgers!tut.cis.ohio-state.edu!ucbvax!agate!bionet!ig!arizona!rupley
  1137. XFrom: rupley@arizona.edu (John Rupley)
  1138. XNewsgroups: comp.emacs
  1139. XSubject: Microemacs 3.10 - patch for tcap.c
  1140. XMessage-ID: <11487@megaron.arizona.edu>
  1141. XDate: 9 Jun 89 01:17:52 GMT
  1142. XOrganization: U of Arizona CS Dept, Tucson
  1143. XLines: 276
  1144. XKeywords: function key timeout loop for USG; revised ttable[]
  1145. X
  1146. X
  1147. Xcontext diff patch for tcap.c:
  1148. X
  1149. X1) added timeout loop in get1key(), for USG option; without it, one
  1150. Xcannot use the function keys under sys5; it could be made more portable
  1151. Xby #defining the processor speed, or building in a test for it;
  1152. Xcommented-out code gives an alternative solution, without a timeout
  1153. Xloop.
  1154. X
  1155. X2) modified ttable[], to allow shifted function keys and some other stuff.
  1156. X
  1157. X3) sample terminfo, consistent with (2), included in comment.
  1158. X
  1159. X
  1160. XJohn Rupley
  1161. X    uucp: ..{uunet | ucbvax | cmcl2 | hao!ncar!noao}!arizona!rupley!local
  1162. X    internet: rupley!local@megaron.arizona.edu
  1163. X    (H) 30 Calle Belleza, Tucson AZ  85716 - (602) 325-4533
  1164. X    (O) Dept. Biochemistry, Univ. Arizona, Tucson AZ 85721 - (602) 621-3929
  1165. X------------------------------------------------------------------------
  1166. X*** tcap.c    Mon May 22 16:21:08 1989
  1167. X--- ../tcap.c    Fri May 26 13:47:56 1989
  1168. X***************
  1169. X*** 70,75
  1170. X                      
  1171. X  */
  1172. X  
  1173. X  #define termdef 1            /* don't define "term" external */
  1174. X  
  1175. X  #include <stdio.h>
  1176. X
  1177. X--- 70,135 -----
  1178. X                      
  1179. X  */
  1180. X  
  1181. X+ /*
  1182. X+  * a non-portable but generally usable USG option for get1key() is suggested;
  1183. X+  * it allows use of the function keys needed to handle menus, specifically
  1184. X+  * those of .emacsrc and the *.cmd files; 
  1185. X+  *
  1186. X+  * it assumes typeahead() is enabled;
  1187. X+  *
  1188. X+  * the ttable[] bindings include shifted function and keypad keys;
  1189. X+  *
  1190. X+  * following is a sample ansi terminfo file, which has strings for the 
  1191. X+  * normal and shifted keys, and which adheres more-or-less to the 
  1192. X+  * ansi standard;
  1193. X+  *
  1194. X+  * a user without write permission on the system terminfo files likely
  1195. X+  * will have to set up a local TERMINFO environment by use of .profile,
  1196. X+  * and perhaps reprogram the function and keypad strings of the terminal;
  1197. X+  *
  1198. X+  * j.a. rupley, tucson, az  - rupley!local@megaron.arizona.edu
  1199. X+  */
  1200. X+ 
  1201. X+ /*-
  1202. X+ ansi|modified terminfo description 
  1203. X+ # DELETE #...# COMMENTS #...# BEFORE #...# TIC'ING #
  1204. X+ # standard stuff #
  1205. X+     am, xon, cols#80, lines#24, bel=^G, cr=\r, clear=\E[H\E[J, 
  1206. X+     el=\E[K, ed=\E[J, cup=\E[%i%p1%d;%p2%dH, cud1=\n, home=\E[H, 
  1207. X+     cub1=\b, cuf1=\E[C, cuu1=\E[A, dch1=\E[P, dl1=\E[M, blink=\E[5m, 
  1208. X+     bold=\E[1m, smir=\E[4h, invis=\E[8m, rev=\E[7m, smso=\E[7m, 
  1209. X+     smul=\E[4m, sgr0=\E[m, rmir=\E[4l, rmso=\E[0m, rmul=\E[0m, 
  1210. X+     is2=\E[=h, ich1=\E[@, il1=\E[L, 
  1211. X+     dl=\E[%p1%dM, cud=\E[%p1%dB, 
  1212. X+     ich=\E[%p1%d@, il=\E[%p1%dL, cub=\E[%p1%dD, cuf=\E[%p1%dC, 
  1213. X+     cuu=\E[%p1%dA, ind=\n, ht=\t, 
  1214. X+ # function keys - kf0=kf10 #
  1215. X+     kf1=\EOc, kf2=\EOd, kf3=\EOe, kf4=\EOf, 
  1216. X+     kf5=\EOg, kf6=\EOh, kf7=\EOi, kf8=\EOj, kf9=\EOk, 
  1217. X+     kf0=\EOl, kf10=\EOl, 
  1218. X+ # shifted function keys - lf0=lf10 #
  1219. X+ # tricky - store and recover strings as labels #
  1220. X+     lf1=\EOC, lf2=\EOD, lf3=\EOE, lf4=\EOF, 
  1221. X+     lf5=\EOG, lf6=\EOH, lf7=\EOI, lf8=\EOJ, lf9=\EOK, 
  1222. X+     lf0=\EOL, lf10=\EOL, 
  1223. X+ # keypad keys #
  1224. X+     khome=\E[H,    kcuu1=\E[A,    kpp=\E[U, 
  1225. X+     kcub1=\E[D,             kcuf1=\E[C, 
  1226. X+     kll=\E[E,     kcud1=\E[B,     knp=\E[V, 
  1227. X+ # ins #
  1228. X+     kich1=\E[@, 
  1229. X+ # shifted keypad keys #
  1230. X+     ka1=\E[!H,    kri=\E[S,    ka3=\E[!U, 
  1231. X+     kclr=\E[!@,            kel=\E[!A, 
  1232. X+     kc1=\E[!E,    kind=\E[T,    kc3=\E[!V,
  1233. X+ # shifted ins and shifted del #
  1234. X+     kil1=\E[L,            kdch1=\E[P,
  1235. X+ # miscellaneous #
  1236. X+     kdl1=\E[M, 
  1237. X+     cbt=\E[Z, 
  1238. X+     kbs=\b, 
  1239. X+ */
  1240. X+ 
  1241. X  #define termdef 1            /* don't define "term" external */
  1242. X  
  1243. X  #include <stdio.h>
  1244. X***************
  1245. X*** 103,136
  1246. X  } TBIND;
  1247. X  
  1248. X  TBIND ttable[] = {
  1249. X!     "bt",    SHFT | CTRL | 'i',    "",    /* backtab */
  1250. X!     "k1",    SPEC | '1',        "",    /* function key 1 */
  1251. X!     "k2",    SPEC | '2',        "",    /* function key 2 */
  1252. X!     "k3",    SPEC | '3',        "",    /* function key 3 */
  1253. X!     "k4",    SPEC | '4',        "",    /* function key 4 */
  1254. X!     "k5",    SPEC | '5',        "",    /* function key 5 */
  1255. X!     "k6",    SPEC | '6',        "",    /* function key 6 */
  1256. X!     "k7",    SPEC | '7',        "",    /* function key 7 */
  1257. X!     "k8",    SPEC | '8',        "",    /* function key 8 */
  1258. X!     "k9",    SPEC | '9',        "",    /* function key 9 */
  1259. X!     "k0",    SPEC | '0',        "",    /* function key 10 */
  1260. X!     "kA",    CTRL | 'O',        "",    /* insert line */
  1261. X!     "kb",    CTRL | 'H',        "",    /* backspace */
  1262. X!     "kC",    CTRL | 'L',        "",    /* clear screen */
  1263. X!     "kD",    SPEC | 'D',        "",    /* delete character */
  1264. X!     "kd",    SPEC | 'N',        "",    /* down cursor */
  1265. X!     "kE",    CTRL | 'K',        "",    /* clear to end of line */
  1266. X!     "kF",    CTRL | 'V',        "",    /* scroll down */
  1267. X!     "kH",    SPEC | '>',        "",    /* home down [END?] key */
  1268. X!     "kh",    SPEC | '<',        "",    /* home */
  1269. X!     "kI",    SPEC | 'C',        "",    /* insert character */
  1270. X!     "kL",    CTRL | 'K',        "",    /* delete line */
  1271. X!     "kl",    SPEC | 'B',        "",    /* left cursor */
  1272. X!     "kN",    SPEC | 'V',        "",    /* next page */
  1273. X!     "kP",    SPEC | 'Z',        "",    /* previous page */
  1274. X!     "kR",    CTRL | 'Z',        "",    /* scroll down */
  1275. X!     "kr",    SPEC | 'F',        "",    /* right cursor */
  1276. X!     "ku",    SPEC | 'P',        "",    /* up cursor */
  1277. X  };
  1278. X  
  1279. X  #define    NTBINDS    sizeof(ttable)/sizeof(TBIND)
  1280. X
  1281. X--- 163,232 -----
  1282. X  } TBIND;
  1283. X  
  1284. X  TBIND ttable[] = {
  1285. X!     "k1",    SPEC | '1',        "",    /* kf1 /* function key 1 */
  1286. X!     "k2",    SPEC | '2',        "",    /* kf2 /* function key 2 */
  1287. X!     "k3",    SPEC | '3',        "",    /* kf3 /* function key 3 */
  1288. X!     "k4",    SPEC | '4',        "",    /* kf4 /* function key 4 */
  1289. X!     "k5",    SPEC | '5',        "",    /* kf5 /* function key 5 */
  1290. X!     "k6",    SPEC | '6',        "",    /* kf6 /* function key 6 */
  1291. X!     "k7",    SPEC | '7',        "",    /* kf7 /* function key 7 */
  1292. X!     "k8",    SPEC | '8',        "",    /* kf8 /* function key 8 */
  1293. X!     "k9",    SPEC | '9',        "",    /* kf9 /* function key 9 */
  1294. X!     "k0",    SPEC | '0',        "",    /* kf0 /* function key 10 */
  1295. X!     "l1",    SPEC | SHFT | '1',    "",    /* kl1 /* shftd func key 1 */
  1296. X!     "l2",    SPEC | SHFT | '2',    "",    /* kl2 /* shftd func key 2 */
  1297. X!     "l3",    SPEC | SHFT | '3',    "",    /* kl3 /* shftd func key 3 */
  1298. X!     "l4",    SPEC | SHFT | '4',    "",    /* kl4 /* shftd func key 4 */
  1299. X!     "l5",    SPEC | SHFT | '5',    "",    /* kl5 /* shftd func key 5 */
  1300. X!     "l6",    SPEC | SHFT | '6',    "",    /* kl6 /* shftd func key 6 */
  1301. X!     "l7",    SPEC | SHFT | '7',    "",    /* kl7 /* shftd func key 7 */
  1302. X!     "l8",    SPEC | SHFT | '8',    "",    /* kl8 /* shftd func key 8 */
  1303. X!     "l9",    SPEC | SHFT | '9',    "",    /* kl9 /* shftd func key 9 */
  1304. X!     "l0",    SPEC | SHFT | '0',    "",    /* kl0 /* shftd func key 10 */
  1305. X! /* the following key-pad keys and their bindings are obvious */
  1306. X!     "kh",    SPEC | '<',        "",    /* khome /* home */
  1307. X!     "ku",    SPEC | 'P',        "",    /* kcuu1 /* up cursor */
  1308. X!     "kP",    SPEC | 'Z',        "",    /* kpp /* previous page */
  1309. X!     "kl",    SPEC | 'B',        "",    /* kcub1 /* left cursor */
  1310. X!     "kr",    SPEC | 'F',        "",    /* kcuf1 /* right cursor */
  1311. X!     "kH",    SPEC | '>',        "",    /* kll /* home down [END] */
  1312. X!     "kd",    SPEC | 'N',        "",    /* kcud1 /* down cursor */
  1313. X!     "kN",    SPEC | 'V',        "",    /* knp /* next page */
  1314. X! /* the following are less obvious */
  1315. X! /* ins        # kI kich1  insert character */    /* bound to insspace */
  1316. X!     "kI",    SPEC | 'C',        "",    /* kich1 /* insert character */
  1317. X! /* shift del    # kD kdch1  delete character */    /* bound to forwdel */
  1318. X!     "kD",    SPEC | 'D',        "",    /* kdch1 /* delete character */
  1319. X! /* shift ins    # kA kil1  insert line */     /* bound to openline */
  1320. X!     "kA",    CTRL | 'O',        "",    /* kil1 /* insert line */
  1321. X! /* shift up    # kR kri  scroll up */        /* bound to backpage */
  1322. X!     "kR",    CTRL | 'Z',        "",    /* kri /* scroll up */
  1323. X! /* shift down    # kF kind  scroll down */    /* bound to forwpage */
  1324. X!     "kF",    CTRL | 'V',        "",    /* kind /* scroll down */
  1325. X! /* shift left    # kC kclr  clear screen */    /* bound to backword */
  1326. X! /*    "kC",    META | 'B',        "",    /* kclr /* clear screen */
  1327. X!     "kC",    SPEC | CTRL | 'B',    "",    /* kclr /* clear screen */
  1328. X! /* shift right    # kE kel  clear to eol */    /* bound to forwword */
  1329. X! /*    "kE",    META | 'F',        "",    /* kel /* clear to eol */
  1330. X!     "kE",    SPEC | CTRL | 'F',    "",    /* kel /* clear to eol */
  1331. X! /* shift pgup    # K3 ka3  pad upper right */    /* bound to gotobop */
  1332. X! /*    "K3",    META | 'P',        "",    /* ka3 /* pad upper right */
  1333. X!     "K3",    SPEC | CTRL | 'Z',    "",    /* ka3 /* pad upper right */
  1334. X! /* shift pgdn    # K5 kc3  pad lower right */    /* bound to gotoeop */
  1335. X! /*    "K5",    META | 'N',        "",    /* kc3 /* pad lower right */
  1336. X!     "K5",    SPEC | CTRL | 'V',    "",    /* kc3 /* pad lower right */
  1337. X! /* shift home    # K1 ka1  pad upper left */    /* unbound key */
  1338. X!     "K1",    SPEC | CTRL | '<',    "",    /* ka1 /* pad upper left */
  1339. X! /* shift end    # K4 kc1  pad lower left */    /* unbound key */
  1340. X!     "K4",    SPEC | CTRL | '>',    "",    /* kc1 /* pad lower left */
  1341. X! /* shift tab     # bt cbt backtab        /* unbound key */
  1342. X!     "bt",    SHFT | CTRL | 'i',    "",    /* cbt /* backtab */
  1343. X! /* and let's forget the following */
  1344. X! /* alt del    # kL kdl1  delete line */
  1345. X! /*    "kL",    CTRL | 'K',        "",    /* kdl1 /* delete line */
  1346. X! /*    "kb",    CTRL | 'H',        "",    /* kbs /* backspace */
  1347. X! /*    "kC",    CTRL | 'L',        "",    /* kclr /* clear screen */
  1348. X! /*    "kE",    CTRL | 'K',        "",    /* kel /* clear to eol */
  1349. X  };
  1350. X  
  1351. X  #define    NTBINDS    sizeof(ttable)/sizeof(TBIND)
  1352. X***************
  1353. X*** 450,457
  1354. X      /* we don't know how to do this check for a pending char within
  1355. X         1/30th of a second machine independantly in the general System V
  1356. X         case.... so we don't */
  1357. X!     if (kbdmode != PLAY)
  1358. X!         return(CTRL | '[');
  1359. X  #endif
  1360. X  
  1361. X      /* a key is pending within 1/30 of a sec... its an escape sequence */
  1362. X
  1363. X--- 546,586 -----
  1364. X      /* we don't know how to do this check for a pending char within
  1365. X         1/30th of a second machine independantly in the general System V
  1366. X         case.... so we don't */
  1367. X!     /*
  1368. X!      * or... maybe we try it;
  1369. X!      * very non-portable solution;
  1370. X!      * hardware-dependent timing loop;
  1371. X!      * set upper-limit on loop by testing hardware, to get 30 ms;
  1372. X!      * use typahead() to check for waiting input on exit from loop;
  1373. X!      */
  1374. X!     {    int i;
  1375. X!         if (kbdmode != PLAY && typahead() <= 0) {
  1376. X!             /* loop limit set by hardware test */
  1377. X!             /* for 30 ms or a bit less */
  1378. X!             for (i = 0; i < 1500; i++)
  1379. X!                 ;
  1380. X!             if (typahead() <= 0)
  1381. X!                 return(CTRL | '[');
  1382. X!         }
  1383. X!     }
  1384. X!     /*-
  1385. X!      * another way -- using blocking read;
  1386. X!      * problem... when <esc> used as terminator, as in setup for
  1387. X!      * searches, need to give it twice, or whatever;
  1388. X!      * non-portable... assumes ansi standard for function keys and
  1389. X!      * keypad;
  1390. X!      */
  1391. X!     /*
  1392. X!     {
  1393. X!         extern char kbdq;
  1394. X!         extern int kbdqp;
  1395. X! 
  1396. X!         kbdq = ttgetc();
  1397. X!         kbdqp = 1;
  1398. X!         if ((kbdq & 255) != '[' && (kbdq & 255) != 'O')
  1399. X!             return(CTRL | '[');
  1400. X!     }
  1401. X!     */
  1402. X  #endif
  1403. X  
  1404. X      /* a key is pending within 1/30 of a sec... its an escape sequence */
  1405. X***************
  1406. X*** 457,462
  1407. X      /* a key is pending within 1/30 of a sec... its an escape sequence */
  1408. X      cseq[0] = 27;
  1409. X      sp = &cseq[1];
  1410. X      while (sp < &cseq[6]) {
  1411. X          c = ttgetc();
  1412. X          *sp++ = c;
  1413. X
  1414. X--- 586,592 -----
  1415. X      /* a key is pending within 1/30 of a sec... its an escape sequence */
  1416. X      cseq[0] = 27;
  1417. X      sp = &cseq[1];
  1418. X+     *sp = 0;
  1419. X      while (sp < &cseq[6]) {
  1420. X          c = ttgetc();
  1421. X          *sp++ = c;
  1422. X
  1423. X
  1424. END_OF_FILE
  1425. if test 10811 -ne `wc -c <'optional'`; then
  1426.     echo shar: \"'optional'\" unpacked with wrong size!
  1427. fi
  1428. # end of 'optional'
  1429. fi
  1430. echo shar: End of shell archive.
  1431. exit 0
  1432.  
  1433.